package com.ynwt.service;

import com.ynwt.constant.JmsDestinationName;
import com.ynwt.domain.User;
import com.ynwt.jms.QueueClient;
import com.ynwt.model.BaseRequest;
import com.ynwt.repository.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.jms.JMSException;

/**
 * Created by huangying on 2017/6/16.
 */
@Service
public class QrcodeServiceImpl implements QrcodeService {
    /**
     * 获取我的邀请卡
     *
     * @param openid
     */
    @Override
    public void getInvitationCard(String openid) {

        User user = userDao.findOne(openid);

        BaseRequest request = new BaseRequest(user.getUnionid());

        try {
            client.sendAndReceive(request.toString(), JmsDestinationName.GET_INVITATION_CARD, 15000);
        } catch (JMSException e) {
            e.printStackTrace();
        }

    }

    @Autowired
    private QueueClient client;

    @Autowired
    private UserDao userDao;
}
